package com.goldcn.common;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;

import java.io.File;




public class ImportExcel {

    private Object[][] obj;

    public ImportExcel(String pathname) throws Exception {

        //1:创建workbook
        Workbook workbook = Workbook.getWorkbook(new File(pathname));
        // 得到工作簿所有的工作表对象
        Sheet sheet = workbook.getSheet(0);
        //默认选择第一个表,可根据需求遍历所有表
        // 遍历所有行
        int rowsCount = sheet.getRows();
        int columnsCount = sheet.getRow(0).length;
        obj = new Object[rowsCount - 1][columnsCount];
        for (int i = 1; i < sheet.getRows(); i++) {
            // 得到所有列，在输出列中的内容
            Cell[] cells = sheet.getRow(i);
            for (int j = 0; j < cells.length; j++) {
                obj[i - 1][j] = cells[j].getContents() + "";
            }
        }
        workbook.close();
    }


    /**
     * @return the obj
     */
    public Object[][] getObj() {
        return obj;
    }




    }
